# 如何存储

# 如何还原

# 一般方式

my_list = [[1, 2, 3, 4],
           [2, 3, 4, 5],
           [3, 4, 5, 6]]

pattern = "{} {} {} {}\n"
with open("data.txt", "w") as f:
    for sublist in my_list:
        f.write(pattern.format(*sublist))

read_data = []
with open("data.txt", "r") as f:
    lines = f.readlines()
    for line in lines:
        read_data.append([int(i) for i in line.split()])

print(read_data)


# # 简单方式
my_dict = {"name": "中文", "books": ["The stars", "History"]}

with open("1.txt", "w") as f:
    f.write(str(my_dict))

with open("1.txt", "r") as f:
    data = eval(f.read())
print(data)